home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
BARNET
/
FREENET
/
DEVOS
/
FDSOURCE.ARC
/
c
/
error
< prev
next >
Wrap
Text File
|
1996-02-12
|
1KB
|
71 lines
#include <stdio.h>
#ifdef MEMCHECK
# include "MemCheck.h"
#else
# include <stdlib.h>
#endif
#include <string.h>
#include <signal.h>
#include <setjmp.h>
#include "kernel.h"
#include "freedial.h"
#include "error.h"
int line_no=0;
bool errbox(os_error *error, bool cancel)
/* Pop up an error box
* IN msg = error text
* cancel = if !0 then make 'Cancel' button, otherwise only 'OK'
* OUT TRUE if user clicked 'OK' button
*/
{
os_error err;
/**/
err.errnum=error->errnum;
if (line_no!=0)
sprintf(err.errmess, "%s at script line %d", error->errmess, line_no);
else strcpy(err.errmess, error->errmess);
return wimp_report_error(&err, cancel?3:1, APPNAME)==1;
} /* errbox */
void complain(char *s, ...)
{
va_list ap;
os_error error;
/**/
va_start(ap, s);
error.errnum=0;
vsprintf(error.errmess, s, ap);
va_end(ap);
errbox(&error, FALSE);
} /* complain */
bool confirm(char *s, ...)
{
va_list ap;
os_error error;
/**/
va_start(ap, s);
error.errnum=0;
vsprintf(error.errmess, s, ap);
va_end(ap);
return errbox(&error, TRUE);
} /* confirm */
void handler(int sig)
/* Error handling procedure
* Reports error, and quits program if user clicks 'Cancel'
*/
{
extern jmp_buf on_error;
/**/
if (!errbox((os_error *)_kernel_last_oserror(), TRUE))
{ /* clicked 'Cancel' - quit immediately */
wimp_close_down(my_handle);
exit(EXIT_FAILURE);
}
longjmp(on_error, 1);
} /* handler */